<template>
  <div>
    <div class="container">
      <div class="handle-box">
        <el-select v-model="query.case_source" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件来源" class="handle-select mr10">
          <el-option key="1" label="市场查获" value="市场查获"></el-option>
          <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
          <el-option key="3" label="上级交办" value="上级交办"></el-option>
        </el-select>
        <el-select v-model="query.case_type" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件性质" class="handle-select mr10">
          <el-option key="1" label="一般案件" value="一般案件"></el-option>
          <el-option key="2" label="简易案件" value="简易案件"></el-option>
        </el-select>
        <el-input v-model="query.case_number" placeholder="立案编号" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" class="handle-input mr10"></el-input>
        <el-button type="primary" :icon="Search" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)">搜索</el-button>
      </div>
      <el-table :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <!--        <el-table-column prop="case_id" label="案件号" width="100" align="center"></el-table-column>-->
        <el-table-column prop="case_source" label="案件来源" align="center"></el-table-column>
        <el-table-column prop="case_number" label="立案编号" width="200" align="center"></el-table-column>
        <el-table-column prop="case_update_time" label="更新时间"  align="center"></el-table-column>
        <el-table-column prop="case_type" label="案件性质" align="center"></el-table-column>
        <el-table-column prop="date_of_filing" label="立案日期"  align="center"></el-table-column>
        <el-table-column label="调查终结文书状态" align="center" width="180">
          <template #default="scope">
            <div v-if="scope.row.tcs_note_id === '询问笔录已完成'">
              <el-tag :type=" 'danger'">询问笔录已完成 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '已完成' ||
            scope.row.tcs_note_id === '无证经营公示已完成' ||
            scope.row.tcs_note_id ==='调查终结文书已完成'||
            scope.row.tcs_note_id ==='案件处理审批已开始'||
            scope.row.tcs_note_id ==='集体讨论已开始'||
            scope.row.tcs_note_id ==='集体讨论已完成'||
            scope.row.tcs_note_id ==='听证已开始'||
            scope.row.tcs_note_id ==='听证告知书已完成'||
            scope.row.tcs_note_id ==='听证已完成'||
            scope.row.tcs_note_id ==='案件处理审批已完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
            scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
            scope.row.tcs_note_id ==='行政处罚决定书已完成'||
            scope.row.tcs_note_id ==='行政罚款收据上传完成'||
            scope.row.tcs_note_id ==='行政罚款收据已完成'||
            scope.row.tcs_note_id ==='结案报告表已完成'||
            scope.row.tcs_note_id ==='撤案集体讨论准备'||
            scope.row.tcs_note_id ==='撤案集体讨论已开始'">
              <el-tag :type=" 'success'">已完成 </el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操 作" width="300" align="center">
          <template #default="scope">
            <div v-if="scope.row.tcs_note_id === '询问笔录已完成'">
              <el-button text :icon="Edit" class="blue" @click="edit_case_report(scope.row)" >
                调查终结文书查看及确认
              </el-button>
            </div>
            <div v-if="scope.row.tcs_note_id === '已完成' ||
            scope.row.tcs_note_id === '无证经营公示已完成' ||
            scope.row.tcs_note_id ==='调查终结文书已完成'||
            scope.row.tcs_note_id ==='案件处理审批已开始'||
            scope.row.tcs_note_id ==='集体讨论已开始'||
            scope.row.tcs_note_id ==='集体讨论已完成'||
            scope.row.tcs_note_id ==='听证已开始'||
            scope.row.tcs_note_id ==='听证告知书已完成'||
            scope.row.tcs_note_id ==='听证已完成'||
            scope.row.tcs_note_id ==='案件处理审批已完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
            scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
            scope.row.tcs_note_id ==='行政处罚决定书已完成'||
            scope.row.tcs_note_id ==='行政罚款收据上传完成'||
            scope.row.tcs_note_id ==='行政罚款收据已完成'||
            scope.row.tcs_note_id ==='结案报告表已完成'||
            scope.row.tcs_note_id ==='撤案集体讨论准备'||
            scope.row.tcs_note_id ==='撤案集体讨论已开始'">
              <el-button text :icon="Edit" class="blue" @click="view_end_report(scope.row)" >
                查看案件调查终结文书
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
<!--      <div class="pagination">-->
<!--        <el-pagination-->
<!--            background-->
<!--            layout="total, prev, pager, next"-->
<!--            :current-page="query.pageIndex"-->
<!--            :page-size="query.pageSize"-->
<!--            :total="pageTotal"-->
<!--            @current-change="handlePageChange"-->
<!--        ></el-pagination>-->
<!--      </div>-->
    </div>


    <el-dialog title="调查终结文书修改及确认" v-model="Edit_report_Visible" width="50%">
      <el-form label-width="140px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="商户烟草售卖许可证" >
              <el-select v-model="case_end_report_data.mer_id"
                         clearable filterable placeholder="请选择涉嫌案由" :disabled="true">
                <el-option
                        v-for="item in mer_Data"
                        :key="item.mer_id"
                        :label="item.retail_licence_code"
                        :value="item.mer_id"
                >商户名称：{{item.mer_name}}</el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="立案时间" >
              <el-date-picker :disabled="true" v-model="case_end_report_data.date_of_filing" type="datetime" placeholder="选择案发日期" value-format="YYYY-MM-DD HH:mm:ss">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>


        <el-form-item label="涉案烟草种类数目" >
          <el-input v-model="case_end_report_data.tce_type_number" disabled ></el-input>
          {{case_end_report_data.tce_type_number_chinese}}
        </el-form-item>
        <el-form-item label="涉案烟草总数" >
          <el-input v-model="case_end_report_data.tce_number" disabled ></el-input>
          {{case_end_report_data.tce_number_chinese}}
        </el-form-item>
        <el-form-item label="涉案烟草金额" >
          <el-input v-model="case_end_report_data.tce_amount" disabled ></el-input>
          {{case_end_report_data.tce_amount_chinese}}
        </el-form-item>
        <el-form-item label="涉案真烟种类数目" >
          <el-input v-model="case_end_report_data.tce_type_number_t" disabled ></el-input>
          {{case_end_report_data.tce_type_number_t_chinese}}
        </el-form-item>
        <el-form-item label="涉案真烟总数" >
          <el-input v-model="case_end_report_data.tce_number_t" disabled ></el-input>
          {{case_end_report_data.tce_number_t_chinese}}
        </el-form-item>
        <el-form-item label="涉案真烟金额" >
          <el-input v-model="case_end_report_data.tce_amount_t" disabled ></el-input>
          {{case_end_report_data.tce_amount_t_chinese}}
        </el-form-item>
        <el-form-item label="涉案假烟种类数目" >
          <el-input v-model="case_end_report_data.tce_type_number_f" disabled ></el-input>
          {{case_end_report_data.tce_type_number_f_chinese}}
        </el-form-item>
        <el-form-item label="涉案假烟总数" >
          <el-input v-model="case_end_report_data.tce_number_f" disabled ></el-input>
          {{case_end_report_data.tce_number_f_chinese}}
        </el-form-item>
        <el-form-item label="涉案假烟金额" >
          <el-input v-model="case_end_report_data.tce_amount_f" disabled ></el-input>
          {{case_end_report_data.tce_amount_f_chinese}}
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="案件来源" >
              <el-select  v-model="case_end_report_data.case_source" clearable filterable placeholder="请选择案件来源">
                <el-option key="1" label="市场查获" value="市场查获"></el-option>
                <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
                <el-option key="3" label="上级交办" value="上级交办"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="当事人姓名" >
              <el-input v-model="case_end_report_data.tir_person"  ></el-input>
            </el-form-item>
          </el-col>
        </el-row>


        <el-form-item label="当事人身份证号" >
          <el-input v-model="case_end_report_data.tir_id_number"  ></el-input>
        </el-form-item>
        <el-form-item label="当事人住址" >
          <el-input v-model="case_end_report_data.tir_home"  ></el-input>
        </el-form-item>
        <el-form-item label="当事人联系方式" >
          <el-input v-model="case_end_report_data.tel"  ></el-input>
        </el-form-item>

        <el-row>
          <el-col :span="12"><el-form-item label="承办人" >
            <el-select v-model="case_end_report_data.user_id_1"
                       clearable filterable placeholder="请选择承办人" >
              <el-option
                      v-for="item in staff_Data"
                      :key="item.staff_id"
                      :label="item.staff_name"
                      :value="item.staff_id"
              ></el-option>
            </el-select>
          </el-form-item></el-col>
          <el-col :span="12"><el-form-item label="同行人" >
            <el-select v-model="case_end_report_data.user_id_2"
                       clearable filterable placeholder="请选择承办人" >
              <el-option
                      v-for="item in staff_Data"
                      :key="item.staff_id"
                      :label="item.staff_name"
                      :value="item.staff_id"
              ></el-option>
            </el-select>
          </el-form-item></el-col>
        </el-row>
        <el-row >
          <el-col >
            <el-form-item label="卷烟来历" >
              <el-select  v-model="case_end_report_data.cigarette_origin" @change="get_inquiries_record_clause_opinion(case_end_report_data.cigarette_origin)" clearable filterable placeholder="请选择">
                  <el-option
                          v-for="item in inquiries_record_Data"
                          :key="item.answer"
                          :label="item.answer"
                          :value="item.answer"
                  ></el-option>
              </el-select>
            </el-form-item>
          </el-col >

        </el-row>
        <el-form-item >
          <el-input type="textarea" rows="3" v-model="case_end_report_data.cigarette_origin"></el-input>
        </el-form-item>
        <el-row :gutter="24">
          <el-col :span="500">
            <el-form-item label="违法事件" >
              <el-select v-model="case_end_report_data.illegal_behavior1" @change="get_illegal_behavior_clause_opinion(case_end_report_data.illegal_behavior1)" clearable filterable placeholder="请选择">
                <el-option
                        v-for="item in legal_clause_Data"
                        :key="item.illegal_behavior"
                        :label="item.illegal_behavior"
                        :value="item.illegal_behavior"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col >
          <div  align="right">
            <el-button type="primary"  @click="add_illegal_behavior" >添加</el-button>
          </div>
        </el-row>
        <el-form-item >
          <el-input type="textarea" rows="3" v-model="case_end_report_data.illegal_behavior2"></el-input>
        </el-form-item>
        <el-row :gutter="24">
          <el-col :span="500">
            <el-form-item label="违反法律" >
              <el-select v-model="case_end_report_data.violate_law" @change="get_illegal_behavior_clause_opinion(case_end_report_data.violate_law)" clearable filterable placeholder="请选择">
                <el-option
                        v-for="item in legal_clause_Data"
                        :key="item.statutory_penalty_abbreviation"
                        :label="item.statutory_penalty_abbreviation"
                        :value="item.statutory_penalty_abbreviation"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <div align="right">
            <el-button type="primary"  @click="add_violate_law">添加</el-button>
          </div>
        </el-row>
        <el-form-item >
          <el-input type="textarea" rows="3" v-model="case_end_report_data.violate_law1"  ></el-input>
        </el-form-item>
        <el-row :gutter="24">
          <el-col :span="500">
            <el-form-item label="处罚依据" >
              <el-select v-model="case_end_report_data.punish_basis" @change="get_illegal_behavior_clause_opinion(case_end_report_data.punish_basis)" clearable filterable placeholder="请选择">
                <el-option
                        v-for="item in legal_clause_Data"
                        :key="item.statutory_penalty_abbreviation"
                        :label="item.statutory_penalty_abbreviation"
                        :value="item.statutory_penalty_abbreviation"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col >
          <div  align="right">
            <el-button type="primary" @click="add_punish_basis">添加</el-button>
          </div>
        </el-row>
        <el-form-item >
          <el-input type="textarea" rows="3"  v-model="case_end_report_data.punish_basis1" ></el-input>
        </el-form-item>

      </el-form>


      <el-table :data="illeg_evi_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header" >
        <el-table-column prop="evi_id_number" label="证据先行保存通知书编号" align="center"></el-table-column>
        <el-table-column prop="tlc_id" label="案 由"  align="center">
          <template #default="scope">
            <el-select v-model="scope.row.tlc_id" @change="edit_illegal(case_end_report_data.case_id,scope.row.evi_id_number,scope.row.tlc_id)"
                       clearable filterable placeholder="请选择涉嫌案由" >
              <el-option
                  v-for="item in illegal_Data"
                  :key="item.tlc_id"
                  :label="item.illegal_behavior"
                  :value="item.tlc_id"
              >案由：{{item.illegal_behavior}} 级别：{{item.grade}}
              </el-option>
            </el-select>
          </template>
        </el-table-column>
      </el-table>
      &nbsp;
      <el-table :data="evidence_ciga_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <el-table-column prop="evi_id_number" label="保存通知书编号"  align="center" width="150"></el-table-column>
        <el-table-column prop="ciga_variety" label="烟草种类"  align="center"></el-table-column>
        <el-table-column prop="ciga_model" label="烟草规格"  align="center"></el-table-column>
        <el-table-column prop="evi_number" label="烟草数量"  align="center"></el-table-column>
        <el-table-column prop="ciga_type" label="烟草类型"  align="center"></el-table-column>
      </el-table><br>

      <template #footer>
				<span class="dialog-footer">
					<el-button @click="Edit_report_Visible = false">取 消</el-button>
          <el-button type="primary" @click="views_end_report_vie">预 览</el-button>
          <el-button type="primary" @click="create_report_word">打 印</el-button>
					<el-button type="primary" @click="edit_end_record_data">修 改</el-button>
          <el-button type="success" @click="certern_case_report">撤案</el-button>
                  <el-button type="primary" @click="refuse_withdraw_case">提交</el-button>
				</span>
      </template>
    </el-dialog>

    <!--    //查看证据调查终结文书-->
    <el-dialog title="" v-model="View_end_report_Visible" width="34%">
      <html>
      <head>
        <title>调查终结文书</title>
      </head>
      <body>
      <h1 align="center">
        福建省闽侯县烟草专卖局
      </h1>
      <h2 align="center">
        案件调查终结报告
      </h2>
      <table border="1"  style="border-collapse: collapse;" width="100%">
        <tr>
          <th colspan="1" width="15%">案由</th>
          <th colspan="3">{{case_end_report_data.illegal_behavior_data}}</th>
        </tr>
        <tr>
          <th colspan="1">案发地点</th>
          <th colspan="3">{{case_end_report_data.mer_address}}</th>
        </tr>
        <tr>
          <th colspan="1">立案日期</th>
          <th colspan="1">{{case_end_report_data.year}}年{{case_end_report_data.month}}月{{case_end_report_data.day}}日</th>
          <th colspan="1">立案编号</th>
          <th colspan="1">侯烟立[{{case_end_report_data.year}}]{{case_end_report_data.case_number}}号</th>
        </tr>
        <tr>
          <th colspan="1">当事人</th>
          <th colspan="1">{{case_end_report_data.tir_person}}</th>
          <th colspan="1">调查人</th>
          <th colspan="1">{{case_end_report_data.user_name_1}}、{{case_end_report_data.user_name_2}}</th>
        </tr>
        <tr>
          <th colspan="1">证件名称及号码</th>
          <th colspan="3" align="left">身份证号：{{case_end_report_data.tir_id_number}}<br>
            烟草专卖零售许可证号：{{case_end_report_data.retail_licence_code}}
          </th>
        </tr>
        <tr>
          <th colspan="1">住址</th>
          <th colspan="1">{{case_end_report_data.tir_home}}</th>
          <th colspan="1">电话</th>
          <th colspan="1">{{case_end_report_data.tel}}</th>
        </tr>
        <tr>
          <th colspan="1">案件来源及调查经过</th>
          <th colspan="3" align="left">
            &emsp;&emsp;<span >{{case_end_report_data.year}}年{{case_end_report_data.month}}月{{case_end_report_data.day}}日</span>，
            我局专卖执法人员依法对位于<span >{{case_end_report_data.mer_address}}</span>
            的<span >{{case_end_report_data.mer_name}}</span>的当事人<span >{{case_end_report_data.tir_person}}</span>
            出示执法检查证件表明身份后，对该店铺进行检查，并在卷烟柜台以及仓库内发现涉嫌违法的卷烟，品种数量如下：<span >{{case_end_report_data.ciga_data_all}}</span>，
            共计<span >{{case_end_report_data.tce_type_number_chinese}}</span>品种<span >{{case_end_report_data.tce_number_chinese}}</span>
            （证据先行登记保存通知书号：<span >{{ case_end_report_data.evi_data_all }}</span>）。由于当事人无法提供该批卷烟的合法有效证明，
            涉嫌<span >{{case_end_report_data.illegal_behavior}}</span>行为，为了保全证据，我局专卖执法人员对现场执法情况拍照留证，
            经报本局领导批准同意，我局专卖执法人员依法对上述卷烟予以先行登记保存，同时制作检查（勘验）笔录，交当事人<span >{{case_end_report_data.tir_person}}</span>核对无异议后签字确认。
          </th>
        </tr>
        <tr>
          <th colspan="1">违法事实与证据</th>
          <th colspan="3"  align="left">
            &emsp;&emsp;本局于<span >{{case_end_report_data.year}}年{{case_end_report_data.month}}月{{case_end_report_data.day}}日</span>
            对该案进行立案调查。现查实：据当事人
            <span >{{case_end_report_data.tir_person}}</span>陈述，
            <span >{{case_end_report_data.cigarette_origin}}。</span>
            我局卷烟真伪鉴别小组依法进行鉴别，
            <span >{{case_end_report_data.evi_ciga_f}}</span>
            <span >{{case_end_report_data.evi_ciga_t}}</span>
            ，当事人对鉴别结论没有异议。因上述卷烟当事人无法提供相关账册、发票等证据对其进销价格及其进销渠道进行印证,故我局核价小组不予采信，根据福建省烟草专卖局公布的价格信息，
            以案发当日作为核价基准日进行计算，<span >{{case_end_report_data.ciga_amount_f}}</span>
            <span >{{case_end_report_data.ciga_amount_t}}</span>上诉卷烟案值共计
            <span >{{case_end_report_data.tce_amount_chinese}}
            （人民币{{case_end_report_data.tce_amount}}元）</span><br>
            &emsp;&emsp;以上事实，有下列我局执法人员采集的与本案相关的证据为证：<br>
            &emsp;&emsp;证据（一）我局专卖执法人员制作的关于当事人经营场所《检查（勘验）笔录》一份，证明当事人从事违规卷烟销售及现场检查情况。<br>
            &emsp;&emsp;证据（二）我局专卖执法人员制作的《先行登记保存批准书》<span >({{case_end_report_data.evi_data_all}})</span>，
            《先行登记保存通知书》<span >({{case_end_report_data.evi_data_all}})</span>各一份，
            证明当事人经营场所查获涉案卷烟的品种、规格及数量。<br>
            &emsp;&emsp;证据（三）我局专卖执法人员现场拍摄的当事人经营场所及卷烟等《现场照片》一组，证明当事人经营场所现场及卷烟有关情况。<br>
            &emsp;&emsp;证据（四）当事人来接受调查时提供的当事人身份证复印件一份，烟草专卖零售许可证（副本）复印件一份，证明当事人身份、从业资格。<br>
            &emsp;&emsp;证据（五）当事人来接受调查时，我局执法人员制作并由当事人签字确认的《询问（调查）笔录》一份，证明当事人从事违规卷烟进销的具体情况。<br>
            &emsp;&emsp;证据（六）我局卷烟真伪鉴别小组对涉案卷烟进行鉴别，制作并由当事人签字确认的《卷烟产品鉴别书》一份，证明该批卷烟真伪情况。<br>
            &emsp;&emsp;证据（七）我局卷烟价格核价小组制作涉案物品核价表一份，证明该批卷烟价格情况。<br>
            &emsp;&emsp;证据（八）我局登记涉案卷烟喷码明细表一份，证明当事人未从福州市烟草公司闽侯分公司进货。<br>
            以上事实清楚，证据确凿，足以认定当事人<span >{{case_end_report_data.tir_person}}</span>
            的行为违反了{{case_end_report_data.violate_law}}的规定，
            构成了{{case_end_report_data.illegal_behavior}}的行为。
          </th>
        </tr>
        <tr>
          <th colspan="1">处罚依据</th>
          <th colspan="3">{{case_end_report_data.punish_basis}}
          </th>
        </tr>
        <tr>
          <th colspan="1">承办人意见</th>
          <th colspan="3" align="left">
            根据违法事实<br>
            <span >&emsp;&emsp;当事人{{case_end_report_data.tir_person}}</span>
            <br>
            &emsp;&emsp;<span >{{case_end_report_data.evi_amount_all}}</span><br>
            &emsp;&emsp;此次卷烟案值共计<span >{{case_end_report_data.tce_amount_chinese}}</span>
            （人民币<span >{{case_end_report_data.tce_amount}}</span>元）<br>
            &emsp;&emsp;案件现已调查终结，请审核。<br>
            &emsp;&emsp;&emsp;&emsp;签字：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <!--            <span style="color: red">{{case_end_report_data.user_name_1}}</span>-->
            执法证号：<span >{{case_end_report_data.user_staff_license_no1}}</span><br>
            &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;

            <!--            <span style="color: red">{{case_end_report_data.user_name_2}}</span>-->
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  执法证号：<span >{{case_end_report_data.user_staff_license_no2}}</span>

          </th>
        </tr>
      </table>
      </body>
      </html>
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="View_end_report_Visible = false">取 消</el-button>
          <el-button type="primary" @click="create_end_report_word">打 印</el-button>
				</span>
      </template>
    </el-dialog>

<!--    &lt;!&ndash;    //查看证据调查终结文书&ndash;&gt;-->
<!--    <el-dialog title="" v-model="View_report_Visible" width="34%">-->
<!--      <html>-->
<!--      <head>-->
<!--        <title>调查终结文书</title>-->
<!--      </head>-->
<!--      <body>-->
<!--      <h1 align="center">-->
<!--        福建省闽侯县烟草专卖局-->
<!--      </h1>-->
<!--      <h2 align="center">-->
<!--        案件调查终结报告-->
<!--      </h2>-->
<!--      <table border="1"  style="border-collapse: collapse;" width="100%">-->
<!--        <tr>-->
<!--          <th colspan="1" width="15%">案由</th>-->
<!--          <th colspan="3">{{case_end_report_data.illegal_behavior_data}}</th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">案发地点</th>-->
<!--          <th colspan="3">{{case_end_report_data.mer_address}}</th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">立案日期</th>-->
<!--          <th colspan="1">{{case_end_report_data.year}}年{{case_end_report_data.month}}月{{case_end_report_data.day}}日</th>-->
<!--          <th colspan="1">立案编号</th>-->
<!--          <th colspan="1">侯烟立[{{case_end_report_data.year}}]{{case_end_report_data.case_number}}号</th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">当事人</th>-->
<!--          <th colspan="1">{{case_end_report_data.tir_person}}</th>-->
<!--          <th colspan="1">调查人</th>-->
<!--          <th colspan="1">{{case_end_report_data.user_name_1}}、{{case_end_report_data.user_name_2}}</th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">证件名称及号码</th>-->
<!--          <th colspan="3" align="left">身份证号：{{case_end_report_data.tir_id_number}}<br>-->
<!--                          烟草专卖零售许可证号：{{case_end_report_data.retail_licence_code}}-->
<!--          </th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">住址</th>-->
<!--          <th colspan="1">{{case_end_report_data.tir_home}}</th>-->
<!--          <th colspan="1">电话</th>-->
<!--          <th colspan="1">{{case_end_report_data.tel}}</th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">案件来源及调查经过</th>-->
<!--          <th colspan="3" align="left">-->
<!--            &emsp;&emsp;<span >{{case_end_report_data.year}}年{{case_end_report_data.month}}月{{case_end_report_data.day}}日</span>，-->
<!--            我局专卖执法人员依法对位于<span >{{case_end_report_data.mer_address}}</span>-->
<!--            的<span >{{case_end_report_data.mer_name}}</span>的当事人<span >{{case_end_report_data.tir_person}}</span>-->
<!--            出示执法检查证件表明身份后，对该店铺进行检查，并在卷烟柜台以及仓库内发现涉嫌违法的卷烟，品种数量如下：<span >{{case_end_report_data.ciga_data_all}}</span>，-->
<!--            共计<span >{{case_end_report_data.tce_type_number_chinese}}</span>品种<span >{{case_end_report_data.tce_number_chinese}}</span>-->
<!--            （证据先行登记保存通知书号：<span >{{ case_end_report_data.evi_data_all }}</span>）。由于当事人无法提供该批卷烟的合法有效证明，-->
<!--            涉嫌<span >{{case_end_report_data.illegal_behavior_data}}</span>行为，为了保全证据，我局专卖执法人员对现场执法情况拍照留证，-->
<!--            经报本局领导批准同意，我局专卖执法人员依法对上述卷烟予以先行登记保存，同时制作检查（勘验）笔录，交当事人<span >{{case_end_report_data.tir_person}}</span>核对无异议后签字确认。-->
<!--          </th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">违法事实与证据</th>-->
<!--          <th colspan="3"  align="left">-->
<!--            &emsp;&emsp;本局于<span >{{case_end_report_data.year}}年{{case_end_report_data.month}}月{{case_end_report_data.day}}日</span>-->
<!--            对该案进行立案调查。现查实：据当事人-->
<!--            <span >{{case_end_report_data.tir_person}}</span>陈述，-->
<!--            <span >{{case_end_report_data.case_source}}</span>-->
<!--            我局卷烟真伪鉴别小组依法进行鉴别，-->
<!--            <span >{{case_end_report_data.evi_ciga_f}}</span>-->
<!--            <span >{{case_end_report_data.evi_ciga_t}}</span>-->
<!--            ，当事人对鉴别结论没有异议。因上述卷烟当事人无法提供相关账册、发票等证据对其进销价格及其进销渠道进行印证,故我局核价小组不予采信，根据福建省烟草专卖局公布的价格信息，-->
<!--            以案发当日作为核价基准日进行计算，<span >{{case_end_report_data.ciga_amount_f}}</span>-->
<!--            <span >{{case_end_report_data.ciga_amount_t}}</span>上诉卷烟案值共计-->
<!--            <span >{{case_end_report_data.tce_amount_chinese}}-->
<!--            （人民币{{case_end_report_data.tce_amount}}元）</span><br>-->
<!--            &emsp;&emsp;以上事实，有下列我局执法人员采集的与本案相关的证据为证：<br>-->
<!--            &emsp;&emsp;证据（一）我局专卖执法人员制作的关于当事人经营场所《检查（勘验）笔录》一份，证明当事人从事违规卷烟销售及现场检查情况。<br>-->
<!--            &emsp;&emsp;证据（二）我局专卖执法人员制作的《先行登记保存批准书》<span >({{case_end_report_data.evi_data_all}})</span>，-->
<!--            《先行登记保存通知书》<span >({{case_end_report_data.evi_data_all}})</span>各一份，-->
<!--            证明当事人经营场所查获涉案卷烟的品种、规格及数量。<br>-->
<!--            &emsp;&emsp;证据（三）我局专卖执法人员现场拍摄的当事人经营场所及卷烟等《现场照片》一组，证明当事人经营场所现场及卷烟有关情况。<br>-->
<!--            &emsp;&emsp;证据（四）当事人来接受调查时提供的当事人身份证复印件一份，烟草专卖零售许可证（副本）复印件一份，证明当事人身份、从业资格。<br>-->
<!--            &emsp;&emsp;证据（五）当事人来接受调查时，我局执法人员制作并由当事人签字确认的《询问（调查）笔录》一份，证明当事人从事违规卷烟进销的具体情况。<br>-->
<!--            &emsp;&emsp;证据（六）我局卷烟真伪鉴别小组对涉案卷烟进行鉴别，制作并由当事人签字确认的《卷烟产品鉴别书》一份，证明该批卷烟真伪情况。<br>-->
<!--            &emsp;&emsp;证据（七）我局卷烟价格核价小组制作涉案物品核价表一份，证明该批卷烟价格情况。<br>-->
<!--            &emsp;&emsp;证据（八）我局登记涉案卷烟喷码明细表一份，证明当事人未从福州市烟草公司闽侯分公司进货。<br>-->
<!--            以上事实清楚，证据确凿，足以认定当事人<span >{{case_end_report_data.tir_person}}</span>-->
<!--            的行为违反了《中华人民共和国烟草专卖法实施条例》第二十三条第二款、《中华人民共和国烟草专卖法实施条例》第二十五条的规定，-->
<!--            构成了销售非法生产的烟草专卖品、未在当地烟草专卖批发企业进货的行为。-->
<!--          </th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">处罚依据</th>-->
<!--          <th colspan="3">《中华人民共和国烟草专卖法实施条例》第五十六条<br>-->
<!--            《中华人民共和国烟草专卖法实施条例》第五十八条-->
<!--          </th>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <th colspan="1">承办人意见</th>-->
<!--          <th colspan="3" align="left">-->
<!--            根据违法事实<br>-->
<!--            &emsp;&emsp;<span >{{case_end_report_data.case_source}}</span><br>-->
<!--            &emsp;&emsp;<span >{{case_end_report_data.evi_amount_all}}</span><br>-->
<!--            &emsp;&emsp;此次卷烟案值共计<span >{{case_end_report_data.tce_amount_chinese}}</span>-->
<!--            （人民币<span >{{case_end_report_data.tce_amount}}</span>元）<br>-->
<!--            &emsp;&emsp;案件现已调查终结，请审核。<br>-->
<!--            &emsp;&emsp;&emsp;&emsp;签字：<span >{{case_end_report_data.user_name_1}}</span>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;执法证号：<span >{{case_end_report_data.user_id_1}}</span><br>-->
<!--            &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<span >{{case_end_report_data.user_name_2}}</span>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;执法证号：<span >{{case_end_report_data.user_id_2}}</span>-->

<!--          </th>-->
<!--        </tr>-->
<!--      </table>-->
<!--      </body>-->
<!--      </html>-->
<!--      <template #footer>-->
<!--				<span class="dialog-footer">-->
<!--					<el-button @click="View_report_Visible = false">取 消</el-button>-->
<!--          <el-button type="primary" @click="create_report_word">打 印</el-button>-->
<!--				</span>-->
<!--      </template>-->
<!--    </el-dialog>-->



  </div>
</template>

<script setup lang="ts" name="basetable">
import { ref, reactive } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Delete, Edit, Search, Plus } from '@element-plus/icons-vue';
import {
  case_evi_Create,
  case_evi_Views,
  case_legal_Create,
  ciga_evudence_Create,
  end_record_data,
  evi_Views,
  fetchData_case,
  fetchData_case_Create,
  fetchData_case_update,
  fetchData_legal_clause,
  fetchData_mer,
  fetchData_s_mongodb_evidence_Cre,
  fetchData_s_mongodb_evidence_Views,
  fetchData_tobacco,
  fetchData_user,
  illegal_record_data,
  illegal_record_Search,
  mer_Create,
  mer_search_api,
  review_price_data,
  staff_evidence_create,
  staff_evidence_data,
  end_record_show,
  record_inquiry_show,
  record_inquiry_print,
  case_evidence_Views,
  case_evidence_Edit,
  illegal_record_update,
  edit_ille_record,
  end_record_update,
  fetchData_interrogator_clause,
  fetchData_inquiries_record_clause,
  fetchData_illegal_behavior_clause,
  add_person,
  add_illegal_law_basis,
  fetchData_information_add,
  law_punish_illegal_behavior_data
} from '../api/index';
import {
  export_word_1, export_word_3, export_word_7,
} from './table_inquiry.vue'

//案件表数据
interface TableItem {
  case_id:number,
  date_of_filing:string,
  date_of_closing:string,
  date_of_archive:string,
  case_source:string,
  case_number:string,
  archive_person:string,
  case_update_time:string,
  ase_type:string,
  case_remark:string,
  tcs_note_id:string,
  ciga_flag:string,
  ciga_num_flag:string,
  mer_flag:string,
}

//获取商户数据用作选项框
interface mer_data {
  mer_id: number,
  mer_format: string,
  mer_address: string,
  mer_person: string,
  mer_record: string,
  date_of_record: string,
  date_of_effect: string,
  date_of_issue: string,
  mer_hometown: string,
  mer_id_number: string,
  mer_tel: string,
  business_licence_code: string,
  licence_state: string,
  storage_address: string,
  retail_licence_code: string,
  category: string,
  area_id: number,
  mer_zip_code: number,
  mer_name: string,
}
const mer_Data = ref<mer_data[]>([]);
const get_mer_opinion = (mer_name:string='',licence_state:string='',mer_person:string='' ,mer_id:number,business_licence_code:string='') =>{
  fetchData_mer(mer_name,licence_state,mer_person,mer_id,business_licence_code).then(res =>{
    mer_Data.value = res.data.data;
  })
}
get_mer_opinion();
//获取执法人员数据作为选择框
interface staff_data{
  staff_id:number,
  staff_name:string,
  staff_gender:string,
  staff_birthday:string,
  staff_ethnicity:string,
  staff_edu_bg:string,
  staff_email:string,
  field_staff_identity_card:string,
  staff_hometown:string,
  staff_degree:string,
  staff_political_status:string,
  staff_post:string,
  staff_account_no:string,
  staff_account_pwd:string,
  staff_starting_time:string,
  staff_authorized:string,
  staff_phone:string,
  staff_tel:string,
  staff_e_sign:string,
  staff_small_number:string,
  staff_license_no:string,
  staff_now_work_degree:string,
  staff_now_evaluate_degree:string,
}
const staff_Data = ref<staff_data[]>([]);
const get_staff_opinion1 = () =>{
  fetchData_user('','','').then(res=>{
    staff_Data.value = res.data.data;
  })
}
get_staff_opinion1();

//获取案由信息数据用作选项框
interface illegal_data {
  tlc_id:number,
  illegal_behavior:string,
  standard:string,
  penalty_range:string,
  statutory_penalty:string,
  grade:string,
  remark:string,
}
const illegal_Data = ref<illegal_data[]>([]);
const get_legal_clause_opinion = (illegal_behavior:string='',standard:string='' ,grade:string='',tlc_id:number) =>{
  fetchData_legal_clause(illegal_behavior, standard,grade,tlc_id).then(res =>{
    illegal_Data.value = res.data.data;
  })
}
get_legal_clause_opinion();


//视图/
const Edit_report_Visible = ref(false);                               //修改立案报告书视图
const View_report_Visible = ref(false);                               //查看立案报告书视图
const View_end_report_Visible=ref(false);                                 //调查终结文书视图
//通过案件号查询所有证据先行保存通知书
interface Evidence_case_data {
  case_id:number,//案件号
  evi_id_number:string,
  evi_number:number,
  tce_time_year:string,//案件时间
  tce_time_month:string,
  tce_time_day:string,
  tce_type_number:string,
  tce_number:string,
  tce_amount:number,
  tce_remark:string,
  tce_address:string,
}
const evidence_case_Data= ref<Evidence_case_data[]>([]);
const get_evidence_case_Data = (case_id:number) =>{
  case_evi_Views("" ,case_id).then(res=>{
    evidence_case_Data.value = res.data.data;
  })
}

// 打印立案报告书
const create_report_word = () =>{
  edit_end_record_data();
  get_case_report_data(case_end_report_data.case_id);
  export_word_7(case_end_report_data.year,
      case_end_report_data.case_number,
      case_end_report_data.list1,
      case_end_report_data.case_source,
      case_end_report_data.month,
      case_end_report_data.day,
      case_end_report_data.hour,
      case_end_report_data.min,
      case_end_report_data.mer_address,
      case_end_report_data.tir_person,
      case_end_report_data.user_name_1,
      case_end_report_data.user_name_2,
      case_end_report_data.user_id_1,
      case_end_report_data.user_id_2,
      case_end_report_data.tir_id_number,
      case_end_report_data.tel,
      case_end_report_data.evi_ciga_f,
      case_end_report_data.evi_ciga_t,
      case_end_report_data.ciga_amount_f,
      case_end_report_data.ciga_amount_t,
      case_end_report_data.tce_amount_chinese,
      case_end_report_data.tce_amount,
      case_end_report_data.retail_licence_code,
      case_end_report_data.mer_id_number,
      case_end_report_data.mer_hometown,
      case_end_report_data.area_name,
      case_end_report_data.mer_name,
      case_end_report_data.list2,
      case_end_report_data.tce_type_number,
      case_end_report_data.tce_type_number_chinese,
      case_end_report_data.tce_number,
      case_end_report_data.list3,
      case_end_report_data.list4,
      case_end_report_data.list5,
      case_end_report_data.list6,
      case_end_report_data.list7,
      case_end_report_data.list8,);
}
//修改 案由
const edit_illegal =(case_id:number,evi_id_number:string='',tlc_id:number) =>{
  edit_ille_record(case_id,evi_id_number,tlc_id).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('修改案由成功');

    }else {
      ElMessageBox.confirm('修改失败', '提示', {
        type: 'warning'
      })
    }
  })
}

//获取询问笔录信息
interface Inquiries_record_data{
  id:number,
  question:string,
  answer:string
}
const inquiries_record_Data= ref<Inquiries_record_data[]>([]);
const get_inquiries_record_clause_opinion=(case_id:number,id:number,question:string,answer:string)=>{
  fetchData_inquiries_record_clause(case_end_report_data.case_id,id,question,answer).then(res=>{
    inquiries_record_Data.value=res.data.data
  })
}

const view_end_report=(row:any)=>{
  create_case.case_id=row.case_id;
  get_case_end_report_data(create_case.case_id);
  get_law_punish_illegal_behavior_data();
  View_end_report_Visible.value=true
}

const get_law_punish_illegal_behavior_data=()=>{
  law_punish_illegal_behavior_data(create_case.case_id).then(res=>{
    case_end_report_data.cigarette_origin=res.data.data.cigarette_origin,
            case_end_report_data.violate_law=res.data.data.violate_law,
            case_end_report_data.illegal_behavior=res.data.data.illegal_behavior,
            case_end_report_data.punish_basis=res.data.data.punish_basis
  })
}

//获取调查终结文书中的数据
const get_case_end_report_data= (case_id:number) =>{
  case_end_report_data.case_id = case_id
  case_end_report_data.ciga_data_t = ""
  case_end_report_data.ciga_data_f = ""
  case_end_report_data.evi_data_all = ""
  case_end_report_data.ciga_data_all= ""
  case_end_report_data.evi_data_t = ""
  case_end_report_data.evi_data_f = ""
  case_end_report_data.evi_ciga_t= ""
  case_end_report_data.evi_ciga_f= ""
  case_end_report_data.evi_amount_all= ""
  case_end_report_data.illegal_behavior_data = ""
  case_end_report_data.case_id = case_id
  end_record_data(case_id).then(res=>{
            case_end_report_data.date_of_filing = res.data.data.date_of_filing;
            case_end_report_data.tir_person = res.data.data.tir_person;
            case_end_report_data.tir_id_number = res.data.data.tir_id_number;
            case_end_report_data.tel = res.data.data.tel;
            case_end_report_data.tir_home = res.data.data.tir_home;
            case_end_report_data.user_id_1 = res.data.data.user_id_1;
            case_end_report_data.user_id_2 = res.data.data.user_id_2;
            case_end_report_data.user_name_1 = res.data.data.user_name_1;
            case_end_report_data.user_name_2 = res.data.data.user_name_2;
            case_end_report_data.user_staff_license_no1=res.data.data.user_staff_license_no1;
    case_end_report_data.user_staff_license_no2=res.data.data.user_staff_license_no2;
            case_end_report_data.case_source = res.data.data.case_source;
            case_end_report_data.case_number = res.data.data.case_number;
            case_end_report_data.mer_id = res.data.data.mer_id;
            case_end_report_data.year = res.data.data.year;
            case_end_report_data.month = res.data.data.month;
            case_end_report_data.day = res.data.data.day;
            case_end_report_data.hour = res.data.data.hour;
            case_end_report_data.min = res.data.data.min;
            case_end_report_data.mer_address = res.data.data.mer_address;
            case_end_report_data.mer_person = res.data.data.mer_person;
            case_end_report_data.mer_id_number = res.data.data.mer_id_number;
            case_end_report_data.mer_hometown = res.data.data.mer_hometown;
            case_end_report_data.mer_name = res.data.data.mer_name;
            case_end_report_data.retail_licence_code = res.data.data.retail_licence_code;
            case_end_report_data.area_name = res.data.data.area_name;
            case_end_report_data.tce_type_number = res.data.data.tce_type_number;
            case_end_report_data.tce_type_number_chinese = res.data.data.tce_type_number_chinese;
            case_end_report_data.tce_number = res.data.data.tce_number;
            case_end_report_data.tce_amount = res.data.data.tce_amount;
            case_end_report_data.tce_number_chinese = res.data.data.tce_number_chinese;
            case_end_report_data.tce_amount_chinese = res.data.data.tce_amount_chinese;
            case_end_report_data.tce_number_f = res.data.data.tce_number_f;
            case_end_report_data.tce_amount_f = res.data.data.tce_amount_f;
            case_end_report_data.tce_number_f_chinese = res.data.data.tce_number_f_chinese;
            case_end_report_data.tce_amount_f_chinese = res.data.data.tce_amount_f_chinese;
            case_end_report_data.tce_type_number_f = res.data.data.tce_type_number_f;
            case_end_report_data.tce_type_number_f_chinese = res.data.data.tce_type_number_f_chinese;
            case_end_report_data.tce_number_t  = res.data.data.tce_number_t ;
            case_end_report_data.tce_amount_t = res.data.data.tce_amount;
            case_end_report_data.tce_number_t_chinese = res.data.data.tce_number_t_chinese;
            case_end_report_data.tce_amount_t_chinese = res.data.data.tce_amount_t_chinese;
            case_end_report_data.tce_type_number_t = res.data.data.tce_type_number_t;
            case_end_report_data.tce_type_number_t_chinese = res.data.data.tce_type_number_t_chinese;
            case_end_report_data.list1 = res.data.data.list1;
            case_end_report_data.list2 = res.data.data.list2;
            case_end_report_data.list3 = res.data.data.list3;
            case_end_report_data.list4 = res.data.data.list4;
            case_end_report_data.list5 = res.data.data.list5;
            case_end_report_data.list6 = res.data.data.list6;
            case_end_report_data.list7 = res.data.data.list7;
            case_end_report_data.list8 = res.data.data.list8;
            evidence_ciga_Data.value = res.data.data.list2
            illeg_evi_Data.value = res.data.data.list3
            //案由
            res.data.data.list1.forEach(function (item) {
              case_end_report_data.illegal_behavior_data = case_end_report_data.illegal_behavior_data + item.illegal_behavior + '、'
            });
            //所有烟草
            res.data.data.list2.forEach(function (item) {
              case_end_report_data.ciga_data_all = case_end_report_data.ciga_data_all + '“' + item.ciga_model + ' ' + item.ciga_variety +
                      '“'+item.evi_number+'条，'
            });
            //假烟
            res.data.data.list4.forEach(function (item) {
              case_end_report_data.ciga_data_f = case_end_report_data.ciga_data_f + '“' + item.ciga_model + ' ' + item.ciga_variety +
                      '“'+item.evi_number+'条，'
            });
            //真烟
            res.data.data.list6.forEach(function (item) {
              case_end_report_data.ciga_data_t = case_end_report_data.ciga_data_t + '“' + item.ciga_model + ' ' + item.ciga_variety +
                      '“'+item.evi_number+'条，'
            });
            //所有证据先行保存通知书
            res.data.data.list3.forEach(function (item) {
              case_end_report_data.evi_data_all = case_end_report_data.evi_data_all + '侯烟存通字【'+ case_end_report_data.year +'】第'+
                      item.evi_id_number + '号、'
            });
            //假烟证据保存通知书
            res.data.data.list5.forEach(function (item) {
              case_end_report_data.evi_data_f = case_end_report_data.evi_data_f + '侯烟存通字【'+ case_end_report_data.year +'】第'+
                      item + '号、'
            });
            //真烟证据保存通知书
            res.data.data.list7.forEach(function (item) {
              case_end_report_data.evi_data_t = case_end_report_data.evi_data_t + '侯烟存通字【'+ case_end_report_data.year +'】第'+
                      item + '号、'
            });
            //假烟数据＋先行保存通知书
            if (case_end_report_data.ciga_data_f){
              case_end_report_data.evi_ciga_f = "鉴定卷烟"+ case_end_report_data.ciga_data_f +  "总计"+ case_end_report_data.tce_type_number_f_chinese +
                      "品种" + case_end_report_data.tce_number_f_chinese + "（" + case_end_report_data.evi_data_f +"）为假冒注册商标且伪劣卷烟";
            }

            //真烟数据＋先行保存通知书
            if (case_end_report_data.ciga_data_t){
              case_end_report_data.evi_ciga_t = "鉴定卷烟"+ case_end_report_data.ciga_data_t +  "总计"+ case_end_report_data.tce_type_number_t_chinese +
                      "品种" + case_end_report_data.tce_number_t_chinese + "（" + case_end_report_data.evi_data_t +"）为真品卷烟";
            }

            //真烟价格
            if (case_end_report_data.ciga_data_t){
              case_end_report_data.ciga_amount_t = "核定违法卷烟（真品卷烟）价值计人民币"+case_end_report_data.tce_amount_t_chinese+
                      "(人民币"+case_end_report_data.tce_amount_t+"元)；";
            }

            //假烟价格
            if (case_end_report_data.ciga_data_f){
              case_end_report_data.ciga_amount_f = "核定违法卷烟（假冒注册商标且伪劣卷烟）价值计人民币"+case_end_report_data.tce_amount_f_chinese+
                      "(人民币"+case_end_report_data.tce_amount_f+"元)；";
            }

            //所有案件价值
            res.data.data.list8.forEach(function (item) {
              case_end_report_data.evi_amount_all =  case_end_report_data.evi_amount_all  + "在此次"+item.illegal_behavior+"行为中，违规数量："+item.tce_number_chinese+"，违规金额：人民币"+item.tce_amount_chinese+
                      "(人民币"+item.tce_amount+"元)；"
            });

          }
  )
}
// 打印案件调查终结报告
const create_end_report_word = () =>{
  get_case_report_data(case_end_report_data.case_id);
  export_word_7(case_end_report_data.year,
          case_end_report_data.case_number,
          case_end_report_data.list1,
          case_end_report_data.case_source,
          case_end_report_data.month,
          case_end_report_data.day,
          case_end_report_data.hour,
          case_end_report_data.min,
          case_end_report_data.mer_address,
          case_end_report_data.tir_person,
          case_end_report_data.user_name_1,
          case_end_report_data.user_name_2,
          case_end_report_data.user_id_1,
          case_end_report_data.user_id_2,
          case_end_report_data.tir_id_number,
          case_end_report_data.tel,
          case_end_report_data.evi_ciga_f,
          case_end_report_data.evi_ciga_t,
          case_end_report_data.ciga_amount_f,
          case_end_report_data.ciga_amount_t,
          case_end_report_data.tce_amount_chinese,
          case_end_report_data.tce_amount,
          case_end_report_data.retail_licence_code,
          case_end_report_data.mer_id_number,
          case_end_report_data.mer_hometown,
          case_end_report_data.area_name,
          case_end_report_data.mer_name,
          case_end_report_data.list2,
          case_end_report_data.tce_type_number,
          case_end_report_data.tce_type_number_chinese,
          case_end_report_data.tce_number,
          case_end_report_data.list3,
          case_end_report_data.list4,
          case_end_report_data.list5,
          case_end_report_data.list6,
          case_end_report_data.list7,
          case_end_report_data.list8,
          case_end_report_data.illegal_behavior,
          case_end_report_data.punish_basis,
          case_end_report_data.cigarette_origin,
          case_end_report_data.violate_law,
          case_end_report_data.tce_number_chinese
  );
}

//获取违法事件信息选项
interface Legal_clause_data{
  tlc_id:number,
  illegal_behavior:string,
  grade:string,
  standard:string,
  penalty_range:string,
  statutory_penalty:string,
  remark:string,
  statutory_penalty_abbreviation:string,
}
const legal_clause_Data=ref<Legal_clause_data[]>([]);
const get_illegal_behavior_clause_opinion=()=>{
  fetchData_illegal_behavior_clause().then(res=>{
    legal_clause_Data.value=res.data.data
  })
}




interface Evidence_ciga_data {
  case_id:number,
  evi_number:number,
  ciga_variety:string,
  barcode:string,
  ciga_model:string,
  ciga_price:number,
  inkjet:string,
  evi_id_number:string,
}
const evidence_ciga_Data= ref<Evidence_ciga_data[]>([]);
// 暂存立案报告表数据
const case_end_report_data = reactive({
  date_of_filing:'',
  tcs_note:'',
  case_id:0,
  tir_person: "",
  tir_id_number: "",
  tir_home:"",
  tel:"",
  user_id_1: "",
  user_id_2: "",
  user_name_1: "",
  user_name_2: "",
  user_staff_license_no1:'',
  user_staff_license_no2:'',
  case_source: "",
  case_number: "",
  mer_id: 0 ,
  year: "",
  month: "",
  day: "",
  hour: "",
  min: "",
  mer_address: "",
  mer_person: "",
  mer_id_number: "",
  mer_hometown: "",
  mer_name: "",
  retail_licence_code: "",
  area_name: "",
  tce_type_number: "",
  tce_type_number_chinese: "",
  tce_number: "",
  tce_amount: "",
  tce_number_chinese: "",
  tce_amount_chinese: "",
  tce_type_number_f: '',
  tce_number_f: '',
  tce_amount_f: '',
  tce_type_number_f_chinese: "",
  tce_number_f_chinese: "",
  tce_amount_f_chinese: "",
  tce_type_number_t: '',
  tce_number_t: "",
  tce_amount_t: "",
  tce_type_number_t_chinese: "",
  tce_number_t_chinese: "",
  tce_amount_t_chinese: "",
  list1:[],
  list2:[],
  list3:[],
  list4:[],
  list5:[],
  list6:[],
  list7:[],
  list8:[],

  illegal_behavior_data : '',
  ciga_data_all : '',
  ciga_data_t : '',
  ciga_data_f : '',
  evi_data_all : '',
  evi_data_t : '',
  evi_data_f : '',
  evi_ciga_t:'',
  evi_ciga_f:'',
  ciga_amount_t:'',
  ciga_amount_f:'',
  evi_amount_all:'',
  cigarette_origin:'',
  violate_law:'',
  violate_law1:'',
  illegal_behavior:'',
  illegal_behavior1:'',
  illegal_behavior2:'',
  punish_basis:'',
  punish_basis1:'',
})
//先行保存通知书与案由对应表
interface Illeg_evi_data {
  evi_id_number:string,
  tlc_id:number,
}
const illeg_evi_Data = ref<Illeg_evi_data[]>([]);
//获取立案报告表中的数据
const get_case_report_data= (case_id:number) =>{
  case_end_report_data.case_id = case_id,
  case_end_report_data.ciga_data_all=''
  case_end_report_data.evi_data_all =''
  //case_end_report_data.evi_data_all_1=''
  case_end_report_data.ciga_data_t =''
  case_end_report_data.evi_ciga_t =''
  case_end_report_data.ciga_data_f =''
  case_end_report_data.evi_ciga_f=''
  end_record_data(case_id).then(res=>{
    case_end_report_data.date_of_filing = res.data.data.date_of_filing;
        case_end_report_data.tir_person = res.data.data.tir_person;
        case_end_report_data.tir_id_number = res.data.data.tir_id_number;
        case_end_report_data.tel = res.data.data.tel;
        case_end_report_data.tir_home = res.data.data.tir_home;
        case_end_report_data.user_id_1 = res.data.data.user_id_1;
        case_end_report_data.user_id_2 = res.data.data.user_id_2;
        case_end_report_data.user_name_1 = res.data.data.user_name_1;
        case_end_report_data.user_name_2 = res.data.data.user_name_2;
        case_end_report_data.user_staff_license_no1=res.data.data.user_staff_license_no1;
    case_end_report_data.user_staff_license_no2=res.data.data.user_staff_license_no2;
        case_end_report_data.case_source = res.data.data.case_source;
        case_end_report_data.case_number = res.data.data.case_number;
        case_end_report_data.mer_id = res.data.data.mer_id;
        case_end_report_data.year = res.data.data.year;
        case_end_report_data.month = res.data.data.month;
        case_end_report_data.day = res.data.data.day;
        case_end_report_data.hour = res.data.data.hour;
        case_end_report_data.min = res.data.data.min;
        case_end_report_data.mer_address = res.data.data.mer_address;
        case_end_report_data.mer_person = res.data.data.mer_person;
        case_end_report_data.mer_id_number = res.data.data.mer_id_number;
        case_end_report_data.mer_hometown = res.data.data.mer_hometown;
        case_end_report_data.mer_name = res.data.data.mer_name;
        case_end_report_data.retail_licence_code = res.data.data.retail_licence_code;
        case_end_report_data.area_name = res.data.data.area_name;
        case_end_report_data.tce_type_number = res.data.data.tce_type_number;
        case_end_report_data.tce_type_number_chinese = res.data.data.tce_type_number_chinese;
        case_end_report_data.tce_number = res.data.data.tce_number;
        case_end_report_data.tce_amount = res.data.data.tce_amount;
        case_end_report_data.tce_number_chinese = res.data.data.tce_number_chinese;
        case_end_report_data.tce_amount_chinese = res.data.data.tce_amount_chinese;
        case_end_report_data.tce_number_f = res.data.data.tce_number_f;
        case_end_report_data.tce_amount_f = res.data.data.tce_amount_f;
        case_end_report_data.tce_number_f_chinese = res.data.data.tce_number_f_chinese;
        case_end_report_data.tce_amount_f_chinese = res.data.data.tce_amount_f_chinese;
        case_end_report_data.tce_type_number_f = res.data.data.tce_type_number_f;
        case_end_report_data.tce_type_number_f_chinese = res.data.data.tce_type_number_f_chinese;
        case_end_report_data.tce_number_t  = res.data.data.tce_number_t ;
        case_end_report_data.tce_amount_t = res.data.data.tce_amount;
        case_end_report_data.tce_number_t_chinese = res.data.data.tce_number_t_chinese;
        case_end_report_data.tce_amount_t_chinese = res.data.data.tce_amount_t_chinese;
        case_end_report_data.tce_type_number_t = res.data.data.tce_type_number_t;
        case_end_report_data.tce_type_number_t_chinese = res.data.data.tce_type_number_t_chinese;
        case_end_report_data.list1 = res.data.data.list1;
        case_end_report_data.list2 = res.data.data.list2;
        case_end_report_data.list3 = res.data.data.list3;
        case_end_report_data.list4 = res.data.data.list4;
        case_end_report_data.list5 = res.data.data.list5;
        case_end_report_data.list6 = res.data.data.list6;
        case_end_report_data.list7 = res.data.data.list7;
        case_end_report_data.list8 = res.data.data.list8;
        case_end_report_data.illegal_behavior2=res.data.data.illegal_behavior2;
        case_end_report_data.punish_basis1=res.data.data.punish_basis1;
        case_end_report_data.violate_law1=res.data.data.violate_law1;
        evidence_ciga_Data.value = res.data.data.list2
        illeg_evi_Data.value = res.data.data.list3

    //案由
        res.data.data.list1.forEach(function (item) {
          case_end_report_data.illegal_behavior_data = case_end_report_data.illegal_behavior_data + item.illegal_behavior + '、'
        });
    //所有烟草
        res.data.data.list2.forEach(function (item) {
          case_end_report_data.ciga_data_all = case_end_report_data.ciga_data_all + '“' + item.ciga_model + ' ' + item.ciga_variety +
              '“'+item.evi_number+'条，'
        });
    //假烟
        res.data.data.list4.forEach(function (item) {
          case_end_report_data.ciga_data_f = case_end_report_data.ciga_data_f + '“' + item.ciga_model + ' ' + item.ciga_variety +
              '“'+item.evi_number+'条，'
        });
    //真烟
    res.data.data.list6.forEach(function (item) {
      case_end_report_data.ciga_data_t = case_end_report_data.ciga_data_t + '“' + item.ciga_model + ' ' + item.ciga_variety +
          '“'+item.evi_number+'条，'
    });
        //所有证据先行保存通知书
        res.data.data.list3.forEach(function (item) {
          case_end_report_data.evi_data_all = case_end_report_data.evi_data_all + '侯烟存通字【'+ case_end_report_data.year +'】第'+
              item.evi_id_number + '号、'
        });
    //假烟证据保存通知书
    res.data.data.list5.forEach(function (item) {
      case_end_report_data.evi_data_f = case_end_report_data.evi_data_f + '侯烟存通字【'+ case_end_report_data.year +'】第'+
          item + '号、'
    });
    //真烟证据保存通知书
    res.data.data.list7.forEach(function (item) {
      case_end_report_data.evi_data_t = case_end_report_data.evi_data_t + '侯烟存通字【'+ case_end_report_data.year +'】第'+
          item + '号、'
    });
    //假烟数据＋先行保存通知书
    if (case_end_report_data.ciga_data_f){
      case_end_report_data.evi_ciga_f = "鉴定卷烟"+ case_end_report_data.ciga_data_f +  "总计"+ case_end_report_data.tce_type_number_f_chinese +
          "品种" + case_end_report_data.tce_number_f_chinese + "（" + case_end_report_data.evi_data_f +"）为假冒注册商标且伪劣卷烟";
    }

    //真烟数据＋先行保存通知书
    if (case_end_report_data.ciga_data_t){
      case_end_report_data.evi_ciga_t = "鉴定卷烟"+ case_end_report_data.ciga_data_t +  "总计"+ case_end_report_data.tce_type_number_t_chinese +
          "品种" + case_end_report_data.tce_number_t_chinese + "（" + case_end_report_data.evi_data_t +"）为真品卷烟";
    }

    //真烟价格
    if (case_end_report_data.ciga_data_t){
      case_end_report_data.ciga_amount_t = "核定违法卷烟（真品卷烟）价值计人民币"+case_end_report_data.tce_amount_t_chinese+
          "(人民币"+case_end_report_data.tce_amount_t+"元)；";
    }

    //假烟价格
    if (case_end_report_data.ciga_data_f){
      case_end_report_data.ciga_amount_f = "核定违法卷烟（假冒注册商标且伪劣卷烟）价值计人民币"+case_end_report_data.tce_amount_f_chinese+
          "(人民币"+case_end_report_data.tce_amount_f+"元)；";
    }

    //所有案件价值
    res.data.data.list8.forEach(function (item) {
      case_end_report_data.evi_amount_all =  case_end_report_data.evi_amount_all  + "在此次"+item.illegal_behavior+"行为中，违规数量："+item.tce_number_chinese+"，违规金额：人民币"+item.tce_amount_chinese+
          "(人民币"+item.tce_amount+"元)；"
    });

      }
  )
}
// 修改立案报告表中的信息
const edit_end_record_data = () =>{
  end_record_update(case_end_report_data.case_id,case_end_report_data.mer_id,case_end_report_data.date_of_filing,case_end_report_data.case_source,case_end_report_data.tir_person,
      case_end_report_data.tir_id_number,case_end_report_data.case_number,case_end_report_data.user_id_1,case_end_report_data.user_id_2,case_end_report_data.tel
  ,case_end_report_data.tir_home).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('修改成功');

    }else {
      ElMessageBox.confirm('修改失败', '提示', {
        type: 'warning'
      })
    }
  })
}
// 完成调查终结文书报告表（撤案）
const certern_case_report = () => {
  if(case_end_report_data.tir_person.length==0){
    alert("请输入当事人姓名")
  }else if(case_end_report_data.tir_id_number.length==0){
    alert("请输入当事人身份证号")
  }else if(case_end_report_data.tir_home.length==0){
    alert("请输入当事人家庭住址")
  }else if(case_end_report_data.tel.length==0){
    alert("请输入当事人联系电话")
  }else if(case_end_report_data.user_id_1.length==0){
    alert("请选择承办人")
  }else if(case_end_report_data.user_id_2.length==0){
    alert("请选择同行人")
  }else if(case_end_report_data.cigarette_origin.length==0){
    alert("请输入卷烟来历")
  }else if(case_end_report_data.illegal_behavior2.length==0){
    alert("请输入当事人违法事件")
  }else if(case_end_report_data.violate_law1.length==0){
    alert("请输入当事人所违反法律")
  }else if(case_end_report_data.punish_basis1.length==0){
    alert("请输入处罚依据")
  }else{
    case_end_report_data.tcs_note = "撤案集体讨论准备"
    fetchData_information_add(case_end_report_data.case_id,case_end_report_data.cigarette_origin,case_end_report_data.illegal_behavior2,
            case_end_report_data.violate_law1,case_end_report_data.punish_basis1).then(res=>{
      if (res.data.message === "success"){
        getData();
      }else{
        ElMessageBox.confirm('确认失败', '提示', {
          type: 'warning'
        })
      }
    })
    fetchData_case_update(case_end_report_data.case_id, case_end_report_data.tcs_note).then(res => {
      if (res.data.message === "success") {
        ElMessage.success('操作成功');
        getData();
        Edit_report_Visible.value = false;
      } else {
        ElMessageBox.confirm('操作失败', '提示', {
          type: 'warning'
        })
      };
    })
  }


}
//   fetchData_information_add(case_end_report_data.case_id,case_end_report_data.cigarette_origin,case_end_report_data.illegal_behavior2,
//   case_end_report_data.violate_law1,case_end_report_data.punish_basis1).then(res=>{
//
//   }
// })


//添加违法事件
const add_illegal_behavior = () => {
  add_illegal_law_basis(case_end_report_data.illegal_behavior2, case_end_report_data.illegal_behavior1).then(res => {
    case_end_report_data.illegal_behavior2 = res.data.data.add_information
  })
}

//添加违反法律
const add_violate_law = () => {
  add_illegal_law_basis(case_end_report_data.violate_law1, case_end_report_data.violate_law).then(res => {
    case_end_report_data.violate_law1 = res.data.data.add_information
  })
}

//添加处罚依据
const add_punish_basis=()=>{
  add_illegal_law_basis(case_end_report_data.punish_basis1, case_end_report_data.punish_basis).then(res => {
    case_end_report_data.punish_basis1 = res.data.data.add_information
  })
}


//不撤案
const refuse_withdraw_case = () => {
  if(case_end_report_data.tir_person.length==0){
    alert("请输入当事人姓名")
  }else if(case_end_report_data.tir_id_number.length==0){
    alert("请输入当事人身份证号")
  }else if(case_end_report_data.tir_home.length==0){
    alert("请输入当事人家庭住址")
  }else if(case_end_report_data.tel.length==0){
    alert("请输入当事人联系电话")
  }else if(case_end_report_data.user_id_1.length==0){
    alert("请选择承办人")
  }else if(case_end_report_data.user_id_2.length==0){
    alert("请选择同行人")
  }else if(case_end_report_data.cigarette_origin.length==0){
    alert("请输入卷烟来历")
  }else if(case_end_report_data.illegal_behavior2.length==0){
    alert("请输入当事人违法事件")
  }else if(case_end_report_data.violate_law1.length==0){
    alert("请输入当事人所违反法律")
  }else if(case_end_report_data.punish_basis1.length==0){
    alert("请输入处罚依据")
  }else{
    case_end_report_data.tcs_note = "调查终结文书已完成"
    fetchData_information_add(case_end_report_data.case_id,case_end_report_data.cigarette_origin,case_end_report_data.illegal_behavior2,
            case_end_report_data.violate_law1,case_end_report_data.punish_basis1).then(res=>{
      if (res.data.message === "success"){
        getData();
      }else{
        ElMessageBox.confirm('确认失败', '提示', {
          type: 'warning'
        })
      }
    })
    fetchData_case_update(case_end_report_data.case_id, case_end_report_data.tcs_note).then(res => {
      if (res.data.message === "success") {
        ElMessage.success('操作成功');
        getData();
        Edit_report_Visible.value = false;
      } else {
        ElMessageBox.confirm('操作失败', '提示', {
          type: 'warning'
        })
      }
    })
  }

}

// 查看立案报告表视图
const views_end_report_vie = () => {
  View_report_Visible.value = true;
}

const create_case = reactive({
  case_id: 0,
})

// 列表中的按钮
// 修改调查终结文书表
const edit_case_report = (row: any) => {
  create_case.case_id = row.case_id;
  case_end_report_data.case_id = row.case_id;
  get_inquiries_record_clause_opinion();
  get_illegal_behavior_clause_opinion();
  get_case_report_data(row.case_id);
  Edit_report_Visible.value = true;
}

const query = reactive({
  case_source:'',
  case_type:'',
  tcs_note_id:'',
  case_number:'',
  pageIndex: 1,
  pageSize: 10
});
const tableData = ref<TableItem[]>([]);
const tableList = ref<TableItem[]>([]); // 用于存放分页数据的列表
const pageTotal = ref(0);
const name = localStorage.getItem('ms_username');
// 获取表格数据
const getData = (archive_person: string = '', case_id: number, case_source: string = '', case_type: string = '', case_number: string = '', tcs_note_id: string = '',name:string='') => {
  fetchData_case(archive_person, case_id, case_source, case_type, case_number, tcs_note_id,name).then(res => {
    tableData.value = res.data.data.filter((i: { tcs_note_id: string; }) => (
            i.tcs_note_id == "询问笔录已完成"||
    i.tcs_note_id =="无证经营公示已完成" ||
    i.tcs_note_id=="调查终结文书已完成"||
    i.tcs_note_id=="案件处理审批已开始"||
    i.tcs_note_id=="集体讨论已开始"||
    i.tcs_note_id=="集体讨论已完成"||
    i.tcs_note_id=="听证已开始"||
    i.tcs_note_id=="听证告知书已完成"||
    i.tcs_note_id=="听证已完成"||
    i.tcs_note_id=="案件处理审批已完成"||
    i.tcs_note_id=="行政处罚事先告知书确认完成"||
    i.tcs_note_id=="行政处罚事先告知书已完成"||
    i.tcs_note_id=="行政处罚决定书确认完成"||
    i.tcs_note_id=="行政处罚决定书已完成"||
    i.tcs_note_id=="行政罚款收据上传完成"||
    i.tcs_note_id=="行政罚款收据已完成"||
    i.tcs_note_id=="结案报告表已完成"||
    i.tcs_note_id=="已完成"||
    i.tcs_note_id=="撤案集体讨论准备"||
    i.tcs_note_id=="撤案集体讨论已开始"
    )  )
    tableList.value = [];
    pageTotal.value = tableData.value.length || 50;
    // 根据页码确定下标位置
    const index: number = query.pageIndex * query.pageSize - query.pageSize;
    for (let i = index; i < index + query.pageSize; i++) {
      // 防止数组下标越界
      if (i <= tableData.value.length - 1) {
        tableList.value.push(tableData.value[i])
      } else {
        // 越界就不再循环
        break;
      }
    }
  });
};
getData('','','','','','',localStorage.getItem('ms_username'));

// 查询操作
const handleSearch = (case_number:string='',tcs_note_id:string='',case_source:string='',case_type:string='') => {
  getData('','',case_source,case_type,case_number,tcs_note_id,localStorage.getItem('ms_username'));
};
// 分页导航
const handlePageChange = (val: number) => {
  query.pageIndex = val;
  getData('','','','','','',localStorage.getItem('ms_username'));
};
</script>

<style scoped>
.handle-box {
  margin-bottom: 20px;
}

/*:deep .el-select-dropdown{*/
/*  max-width: 243px;*/
/*}*/
/*:deep .el-select-dropdown__item{*/
/*  display: inline-block;*/
/*}*/
/*.el-select-dropdown__item span {*/
/*  min-width: 205px;*/
/*  display: inline-block;*/
/*}*/


.handle-select {
  width: 120px;
}

.handle-input {
  width: 300px;
}
.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}

:deep(.avatar){
  width: 100px;
  height: 100px;
}
.blue {
  color: rgba(0, 118, 252, 0.79);
}
.mr10 {
  margin-right: 10px;
}
.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}

/*#inspect_record{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -20px;*/

/*}*/
.handle-box button{
  background-color: #00a854;
}
.dialog-footer button{
  background-color: #00a854;
  color:white;
}
/*#filing_report_review{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -22px;*/
/*}*/
</style>
